package com.springsecutity.secutity.service;

import com.springsecutity.secutity.dao.SysUserRepository;
import com.springsecutity.secutity.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

public class CustomUserService implements UserDetailsService {

    @Autowired
    private SysUserRepository sysUserRepository;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        SysUser username = sysUserRepository.findByUsername(s);
        if (username == null) {
            throw new UsernameNotFoundException("用户查询失败 。。");
        }
        return username;
    }
}
